package com.xmb.wechat.application;

import android.support.v7.app.AppCompatActivity;

import java.util.LinkedList;
import java.util.List;

public class WechatExitApplication extends com.nil.crash.utils.CrashApp {

    private static WechatExitApplication   instance;
    private        List<AppCompatActivity> activityList = new LinkedList<>();

    private WechatExitApplication() {
    }

    public static WechatExitApplication getInstance() {
        if (instance == null) {
            instance = new WechatExitApplication();
        }
        return instance;
    }

    public void addActivity(AppCompatActivity activity) {
        activityList.add(activity);
    }

    /**
     * 退出APP
     */
    public void exit() {
        if (activityList != null && !activityList.isEmpty())
            for (int i = 0; i < activityList.size(); i++) {
                activityList.get(i).finish();
            }
        System.exit(0);
    }
}
